package com.uk.data.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="FATURA")
public  class Fatura implements Serializable{

	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	
	@ManyToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="KONTRATA_ID",referencedColumnName="ID" )
	private Kontrata kontrata;
	
	@Temporal(TemporalType.DATE)
	@Column(name="DATA_LEXIM_AKTUAL")
	private Date dataLeximAktual;
	
	@Column(name="LEXIMI_AKTUAL")
	private double leximiAktual;
	
	
	@Temporal(TemporalType.DATE)
	@Column(name="DATA_LEXIM_KALUAR")
	private Date dataLeximKaluar;
	
	@Column(name="LEXIMI_KALUAR")
	private double leximiKaluar;
	
	@Column(name="HARXHIMI_AFROFE")
	private double harxhimiAfrofe;
	

	private List<Tarifa> tarifaCollection = new ArrayList<Tarifa>();
	
	private String user;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="DATA_REGJISTRIMIT")
	private Date dataRegjistrimit;
	
	private double totali;
	

	
	
	@Column(name="SHUMA_PAGUAR")
	private double shumaPaguar;

	private boolean paguar = false;

	private boolean anulluar = false;
	
	@Column(name="ARSYE_ANULLIMI",length=255)
	private String arsyeAnullimi;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Kontrata getKontrata() {
		return kontrata;
	}

	public void setKontrata(Kontrata kontrata) {
		this.kontrata = kontrata;
	}

	public Date getDataLeximAktual() {
		return dataLeximAktual;
	}

	public void setDataLeximAktual(Date dataLeximAktual) {
		this.dataLeximAktual = dataLeximAktual;
	}

	public double getLeximiAktual() {
		return leximiAktual;
	}

	public void setLeximiAktual(double leximiAktual) {
		this.leximiAktual = leximiAktual;
	}

	public Date getDataLeximKaluar() {
		return dataLeximKaluar;
	}

	public void setDataLeximKaluar(Date dataLeximKaluar) {
		this.dataLeximKaluar = dataLeximKaluar;
	}

	public double getLeximiKaluar() {
		return leximiKaluar;
	}

	public void setLeximiKaluar(double leximiKaluar) {
		this.leximiKaluar = leximiKaluar;
	}

	public double getHarxhimiAfrofe() {
		return harxhimiAfrofe;
	}

	public void setHarxhimiAfrofe(double harxhimiAfrofe) {
		this.harxhimiAfrofe = harxhimiAfrofe;
	}

	public List<Tarifa> getTarifaCollection() {
		return tarifaCollection;
	}

	public void setTarifaCollection(List<Tarifa> tarifaCollection) {
		this.tarifaCollection = tarifaCollection;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public Date getDataRegjistrimit() {
		return dataRegjistrimit;
	}

	public void setDataRegjistrimit(Date dataRegjistrimit) {
		this.dataRegjistrimit = dataRegjistrimit;
	}

	public double getTotali() {
		return totali;
	}

	public void setTotali(double totali) {
		this.totali = totali;
	}

	

	public double getShumaPaguar() {
		return shumaPaguar;
	}

	public void setShumaPaguar(double shumaPaguar) {
		this.shumaPaguar = shumaPaguar;
	}

	public boolean isPaguar() {
		return paguar;
	}

	public void setPaguar(boolean paguar) {
		this.paguar = paguar;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((dataLeximAktual == null) ? 0 : dataLeximAktual.hashCode());
		result = prime * result
				+ ((dataLeximKaluar == null) ? 0 : dataLeximKaluar.hashCode());
		result = prime
				* result
				+ ((dataRegjistrimit == null) ? 0 : dataRegjistrimit.hashCode());
		long temp;
		temp = Double.doubleToLongBits(harxhimiAfrofe);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((kontrata == null) ? 0 : kontrata.hashCode());
		temp = Double.doubleToLongBits(leximiAktual);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(leximiKaluar);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + (paguar ? 1231 : 1237);
		temp = Double.doubleToLongBits(shumaPaguar);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime
				* result
				+ ((tarifaCollection == null) ? 0 : tarifaCollection.hashCode());
		temp = Double.doubleToLongBits(totali);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Fatura other = (Fatura) obj;
		if (dataLeximAktual == null) {
			if (other.dataLeximAktual != null)
				return false;
		} else if (!dataLeximAktual.equals(other.dataLeximAktual))
			return false;
		if (dataLeximKaluar == null) {
			if (other.dataLeximKaluar != null)
				return false;
		} else if (!dataLeximKaluar.equals(other.dataLeximKaluar))
			return false;
		if (dataRegjistrimit == null) {
			if (other.dataRegjistrimit != null)
				return false;
		} else if (!dataRegjistrimit.equals(other.dataRegjistrimit))
			return false;
		if (Double.doubleToLongBits(harxhimiAfrofe) != Double
				.doubleToLongBits(other.harxhimiAfrofe))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (kontrata == null) {
			if (other.kontrata != null)
				return false;
		} else if (!kontrata.equals(other.kontrata))
			return false;
		if (Double.doubleToLongBits(leximiAktual) != Double
				.doubleToLongBits(other.leximiAktual))
			return false;
		if (Double.doubleToLongBits(leximiKaluar) != Double
				.doubleToLongBits(other.leximiKaluar))
			return false;
		if (paguar != other.paguar)
			return false;
		if (Double.doubleToLongBits(shumaPaguar) != Double
				.doubleToLongBits(other.shumaPaguar))
			return false;
		if (tarifaCollection == null) {
			if (other.tarifaCollection != null)
				return false;
		} else if (!tarifaCollection.equals(other.tarifaCollection))
			return false;
		if (Double.doubleToLongBits(totali) != Double
				.doubleToLongBits(other.totali))
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		return true;
	}

	public boolean isAnulluar() {
		return anulluar;
	}

	public void setAnulluar(boolean anulluar) {
		this.anulluar = anulluar;
	}

	public String getArsyeAnullimi() {
		return arsyeAnullimi;
	}

	public void setArsyeAnullimi(String arsyeAnullimi) {
		this.arsyeAnullimi = arsyeAnullimi;
	}
	

}
